//
//  BaseTableTableViewController.swift
//  微博模拟项目
//
//  Created by 尹家鑫 on 16/3/12.
//  Copyright © 2016年 尹家鑫. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController,VisitorLoginViewDelegate {
    
    var userLogin = UserAccount.shareAccount.userLogin
    
    //访客视图属性
    var visitorLoginView: VisitorLoginView?
    
    override func loadView() {
        
        //1.判断用户是否登录
        if userLogin {
            //显示用户相关的数据 -> 加载tabbleView
            super.loadView()
            
        } else {
            visitorLoginView = VisitorLoginView()
            
            view = visitorLoginView
            
            //指定代理
            visitorLoginView?.visitorDelegate = self
            
            navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登录", style: .Plain, target: self, action: "userWillLognin")
            
            navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", style: .Plain, target: self, action: "userWillRegister")
        }
        
    }
    
    //MARK:协议方法
    func userWillLognin() {
        print("用户将要登录")
        
        let oauth = OAuthViewController()
        
        //包装在一个导航视图控制器中 进行 modal
        let nav = UINavigationController(rootViewController: oauth)
        presentViewController(nav, animated: true, completion: nil)
        
    }
    
    func userWillRegister() {
        print("用户将要注册")
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    // MARK: - Table view data source
    
    override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
        // #warning Incomplete implementation, return the number of sections
        return 0
    }
    
    override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        // #warning Incomplete implementation, return the number of rows
        return 0
    }
    
    
}
